<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <rich:panel>
        <f:facet name="header">Relationship Details</f:facet>

        <s:decorate id="id" template="layout/display.xhtml">
            <ui:define name="label">Id</ui:define>
            <h:outputText value="#{relationshipHome.instance.id}"/>
        </s:decorate>

        <s:decorate id="relationName" template="layout/display.xhtml">
            <ui:define name="label">Relation name</ui:define>
            <h:outputText value="#{relationshipHome.instance.relationName}"/>
        </s:decorate>

        <s:decorate id="relationDesc" template="layout/display.xhtml">
            <ui:define name="label">Relation desc</ui:define>
            <h:outputText value="#{relationshipHome.instance.relationDesc}"/>
        </s:decorate>

        <div style="clear:both"/>

    </rich:panel>

    <div class="actionButtons">

        <s:button view="/RelationshipEdit.xhtml"
                    id="edit"
                 value="Edit"/>

        <s:button view="/#{empty relationshipFrom ? 'RelationshipList' : relationshipFrom}.xhtml"
                    id="done"
                 value="Done"/>

    </div>

    <rich:tabPanel switchType="ajax">

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/onetomany.gif" style="vertical-align: middle; padding-right: 4px;"/>Parents</h:panelGroup>
        </f:facet>
    <h:form styleClass="association" id="parentsChildren">

        <h:outputText value="There are no parents associated with this relationship."
                   rendered="#{empty relationshipHome.parents}"/>

        <rich:dataTable value="#{relationshipHome.parents}"
                       var="_parent"
                  rendered="#{not empty relationshipHome.parents}"
                rowClasses="rvgRowOne,rvgRowTwo"
                        id="parentsTable">
            <rich:column sortBy="#{_parent.id}">
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_parent.id}"/>
            </rich:column>
            <rich:column sortBy="#{_parent.firstName}">
                <f:facet name="header">First name</f:facet>
                <h:outputText value="#{_parent.firstName}"/>
            </rich:column>
            <rich:column sortBy="#{_parent.lastName}">
                <f:facet name="header">Last name</f:facet>
                <h:outputText value="#{_parent.lastName}"/>
            </rich:column>
            <rich:column sortBy="#{_parent.mobileNumber}">
                <f:facet name="header">Mobile number</f:facet>
                <h:outputText value="#{_parent.mobileNumber}"/>
            </rich:column>
            <rich:column sortBy="#{_parent.officePhone}">
                <f:facet name="header">Office phone</f:facet>
                <h:outputText value="#{_parent.officePhone}"/>
            </rich:column>
            <rich:column sortBy="#{_parent.email}">
                <f:facet name="header">Email</f:facet>
                <h:outputText value="#{_parent.email}"/>
            </rich:column>
            <h:column>
                <f:facet name="header">Action</f:facet>
                <s:link id="selectparent"
                     value="Select"
                      view="/Parent.xhtml">
                    <f:param name="parentId"
                            value="#{_parent.id}"/>
                    <f:param name="parentFrom" value="Relationship"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </h:form>

    <div class="actionButtons">
        <s:button
               value="Add parent"
                view="/ParentEdit.xhtml">
            <f:param name="relationshipId"
                    value="#{relationshipHome.instance.id}"/>
            <f:param name="parentFrom" value="Relationship"/>
        </s:button>
    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
